home *** CD-ROM | disk | FTP | other *** search
- class Class.Control extends MovieClip
- {
- var distanceMax;
- var _V;
- var line_mc;
- var role;
- var opp;
- var side;
- var onMouseMove;
- var onMouseUp;
- var meter_mc;
- var mouse_mc;
- var startX;
- var startY;
- var distance;
- var angle;
- var Vx;
- var Vy;
- var inDraw = false;
- function Control()
- {
- super();
- this.distanceMax = 200;
- this._V = _root.V;
- this.line_mc = _global.cMC("line_mc",this);
- }
- function init(_role, _opp, _side)
- {
- this.role = _role;
- this.opp = _opp;
- this.side = _side;
- trace("side: " + this.side);
- }
- function activeStart()
- {
- var owner = this;
- _root.drawArea.onPress = function()
- {
- owner.mouseDown();
- };
- this.onMouseMove = this.mouseMove;
- this.onMouseUp = this.mouseUp;
- }
- function activeEnd()
- {
- _root.drawArea.onPress = function()
- {
- };
- this.onMouseMove = null;
- this.onMouseUp = null;
- this.meter_mc._x = -100;
- this.meter_mc._y = -100;
- }
- function useMouseCursor()
- {
- Mouse.hide();
- var owner = this;
- this.mouse_mc.onEnterFrame = function()
- {
- this._x = owner._xmouse;
- trace("this: " + this);
- trace("this._x: " + this._x);
- this._y = owner._ymouse;
- };
- }
- function stopMouseCursor()
- {
- Mouse.show();
- this.mouse_mc.onEnterFrame = null;
- this.mouse_mc._x = -100;
- this.mouse_mc._y = -100;
- }
- function mouseDown()
- {
- this.inDraw = true;
- this.startX = this._xmouse;
- this.startY = this._ymouse;
- this.distance = 10;
- _root.roleNow.setReady();
- }
- function mouseMove()
- {
- if(this.inDraw)
- {
- var _loc4_ = this._xmouse;
- var _loc3_ = this._ymouse;
- this.distance = ExtMath.distance(_loc4_,_loc3_,this.startX,this.startY);
- if(this.distance > this.distanceMax)
- {
- this.distance = this.distanceMax;
- }
- this.angle = ExtMath.angleOfLine(_loc4_,_loc3_,this.startX,this.startY);
- var _loc5_ = this.getPower(this.distance);
- _root.roleNow.setAnimation(_loc5_);
- this.meter_mc._x = _loc4_;
- this.meter_mc._y = _loc3_;
- this.meter_mc.point_mc._rotation = this.angle;
- this.meter_mc.bar.mask_mc._rotation = int(this.distance / this.distanceMax * 180);
- if(this.side == 1)
- {
- this.meter_mc.angle_txt.text = ExtMath.fixAngle(int(- this.angle)) + "┬░";
- }
- else
- {
- this.meter_mc.angle_txt.text = int(this.angle + 180) + "┬░";
- }
- this.meter_mc.power_txt.text = int(this.distance / this.distanceMax * 100) + "%";
- updateAfterEvent();
- }
- }
- function mouseUp()
- {
- if(this.inDraw == false)
- {
- return undefined;
- }
- this.inDraw = false;
- this.startControl();
- }
- function getPower(distance)
- {
- var _loc2_ = distance / this.distanceMax;
- return _loc2_;
- }
- function startControl()
- {
- if(isNaN(this.distance))
- {
- this.distance = 20;
- }
- if(isNaN(this.angle))
- {
- this.angle = 30;
- }
- var _loc3_ = this.distance / this.distanceMax;
- var _loc2_ = this._V * _loc3_;
- this.Vx = _loc2_ * ExtMath.cosD(this.angle);
- this.Vy = _loc2_ * ExtMath.sinD(this.angle);
- this.play();
- this.activeEnd();
- }
- }
-